package cn.com.zpark;

import cn.com.zpark.utils.JDBCUtils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @PackageName: cn.com.zpark
 * @ClassName: JDBC_04_Delete
 * @Description: JDBC删除数据
 * @author: RZS
 * @date: 2021/10/25  15:45
 */
public class JDBC_02_Delete {
    public static void main(String[] args) {
        Connection conn = null;
        Statement stat = null;
        try {

            // 2、获取连接
            conn = JDBCUtils.getConn();
            // 3、创建statement对象
            stat = conn.createStatement();
            // 4、编写sql语句
            String sql = "delete from user where id=3";
            // 5、执行sql
            stat.executeUpdate(sql);
            // 6、获取执行结果
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            // 7、关闭连接
            JDBCUtils.close(null, stat, conn);
        }
    }
}
